/*
package gamecomm.activity;

import android.app.Activity;

import org.json.JSONException;
import org.json.JSONObject;
 
import gamecomm.library.DatabaseHandler;
import gamecomm.library.UserFunctions;
 
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class AddGameActivity extends Activity {
 
    Button btnAddgame;
    EditText gameName;
    EditText gameYear;
    EditText gameSystem;
    TextView addgameErrorMsg;
 
    // JSON Response node names
    private static String KEY_SUCCESS = "success";
    private static String KEY_GAMESYSTEM = "system";
    private static String KEY_NAME = "name";
    private static String KEY_YEAR = "year";
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.addgame);
 
        // Importing all assets like buttons, text fields
        gameName = (EditText) findViewById(R.id.gameName);
        gameYear = (EditText) findViewById(R.id.gameYear);
        gameSystem = (EditText) findViewById(R.id.gameSystem);
        btnAddgame = (Button) findViewById(R.id.btnAddgame);
        addgameErrorMsg = (TextView) findViewById(R.id.addgame_error);
 
        // Addgame Button Click event
        btnAddgame.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                String name = gameName.getText().toString();
                String year = gameYear.getText().toString();
                String system = gameSystem.getText().toString();
                UserFunctions userFunction = new UserFunctions();
                JSONObject json = userFunction.addGame(name, year, system);
 
                // check for login response
                try {
                    if (json.getString(KEY_SUCCESS) != null) {
                        addgameErrorMsg.setText("");
                        String res = json.getString(KEY_SUCCESS);
                        if(Integer.parseInt(res) == 1){
                            // user successfully added game
                            // Store game details in SQLite Database
                            DatabaseHandler db = new DatabaseHandler(getApplicationContext());
                            JSONObject json_user = json.getJSONObject("game");
 
                            // Clear all previous data in database
                            userFunction.logoutUser(getApplicationContext());
                            db.addGame(json_user.getString(KEY_NAME), json_user.getString(KEY_YEAR), json.getString(KEY_GAMESYSTEM));
                            // Launch Dashboard Screen
                            Intent dashboard = new Intent(getApplicationContext(), DashboardActivity.class);
                            // Close all views before launching Dashboard
                            dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                            startActivity(dashboard);
                            // Close Addgame Screen
                            finish();
                        }else{
                            // Error in game add
                        	if(name.matches("") || year.matches("") || system.matches("")){
                        		addgameErrorMsg.setText("There is a missing section");
                        	}else{
                        		addgameErrorMsg.setText("Game Already Exists");
                        		gameYear.setText(null);
                        		gameSystem.setText(null);
                        	}
                        }
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
    }
}
*/
